package com.example.appforpatient.fragment;
import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import com.example.appforpatient.R;
import com.example.appforpatient.adapter.ServiceConnector;
import com.example.appforpatient.adapter.ServiceConnector.MedicalHistory;
import com.example.appforpatient.adapter.ServiceConnector.PhysicianInfo;



import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;

public class FragmentHistorySickness extends Fragment {
 
    public static Fragment newInstance(Context context) {
    	FragmentHistorySickness f = new FragmentHistorySickness();
 
        return f;
    }
 
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_medicalhistorysickness, null);
        TextView list = (TextView)root.findViewById(R.id.tvShowEmercy);

        MedicalHistory pi = ServiceConnector.getSingleton().getPatientHistory();
        
        
		TextView mh_doctor = (TextView) root.findViewById(R.id.mh_doctor);
		mh_doctor.setText(pi.physician);
		
		TextView mh_phone = (TextView) root.findViewById(R.id.mh_phone);
		mh_phone.setText(pi.phone);

		TextView mh_address2 = (TextView) root.findViewById(R.id.mh_address2);
		mh_address2.setText(pi.address);
	      // ===
        
        RadioButton rdQ1Result = (RadioButton) root.findViewById(R.id.rdQ1Result);
        rdQ1Result.setChecked(pi.q1Result);
        RadioButton rdQ2Result = (RadioButton) root.findViewById(R.id.rdQ2Result);
        rdQ2Result.setChecked(pi.q2Result);
        RadioButton rdQ3Result = (RadioButton) root.findViewById(R.id.rdQ3Result);
        rdQ3Result.setChecked(pi.q3Result);
        RadioButton rdQ4Result = (RadioButton) root.findViewById(R.id.rdQ4Result);
        rdQ4Result.setChecked(pi.q4Result);
        
        TextView  tvExplain1= (TextView) root.findViewById(R.id.tvShowExplain1);
        tvExplain1.setText(pi.q1Explain);
        TextView tvExplain2 = (TextView) root.findViewById(R.id.tvShowExplain2);
        tvExplain2.setText(pi.q2Explain);
        TextView tvExplain3 = (TextView) root.findViewById(R.id.tvShowExplain3);
        tvExplain3.setText(pi.q31Explain);
        TextView tvExplain4 = (TextView) root.findViewById(R.id.tvShowExplain4);
        tvExplain4.setText(pi.q4Explain);
	
        
        RadioButton rdHeartDisease = (RadioButton) root.findViewById(R.id.rdHeartDisease);
        rdHeartDisease.setChecked(pi.heartDisease);
        
        RadioButton rdHighBloodPressure = (RadioButton) root.findViewById(R.id.rdHighBloodPressure);
        rdHighBloodPressure.setChecked(pi.highBloodPressure);
        
        RadioButton rdBloodDisease = (RadioButton) root.findViewById(R.id.rdBloodDisease);
        rdBloodDisease.setChecked(pi.bloodDisease);      

        RadioButton rdRheumaticFever = (RadioButton) root.findViewById(R.id.rdRheumaticFever);
        rdRheumaticFever.setChecked(pi.RheumaticFever);
        
        RadioButton rdDiabetes = (RadioButton) root.findViewById(R.id.rdDiabetes);
        rdDiabetes.setChecked(pi.diabetes);
        
        RadioButton rdStroke = (RadioButton) root.findViewById(R.id.rdStroke);
        rdStroke.setChecked(pi.stroke);
        
        RadioButton rdEpilepsy = (RadioButton) root.findViewById(R.id.rdEpilepsy);
        rdEpilepsy.setChecked(pi.epilepsy);
        
        RadioButton rdArthritis = (RadioButton) root.findViewById(R.id.rdArthritis);
        rdArthritis.setChecked(pi.arthritis);
        
        RadioButton rdTumorHistory = (RadioButton) root.findViewById(R.id.rdTumorHistory);
        rdTumorHistory.setChecked(pi.tumorHistory);
        
        
        RadioButton rdVD = (RadioButton) root.findViewById(R.id.rdVD);
        rdVD.setChecked(pi.VD);
        
        RadioButton rdNervousDisorders = (RadioButton) root.findViewById(R.id.rdNervousDisorders);
        rdNervousDisorders.setChecked(pi.nervousDisorders);
        
        RadioButton rdRadiationTreatment = (RadioButton) root.findViewById(R.id.rdRadiationTreatment);
        rdRadiationTreatment.setChecked(pi.radiationTreatment);
        
        RadioButton rdLiverDisease = (RadioButton) root.findViewById(R.id.rdLiverDisease);
        rdLiverDisease.setChecked(pi.liverDisease);
        
        RadioButton rdKidneyDisease = (RadioButton) root.findViewById(R.id.rdKidneyDisease);
        rdKidneyDisease.setChecked(pi.kidneyDisease);
        
        RadioButton rdHepatitis = (RadioButton) root.findViewById(R.id.rdHepatitis);
        rdHepatitis.setChecked(pi.hepatitis);
        
        RadioButton rdAsthma = (RadioButton) root.findViewById(R.id.rdAsthma);
        rdAsthma.setChecked(pi.asthma);
        
        RadioButton rdTuberculosis = (RadioButton) root.findViewById(R.id.rdTuberculosis);
        rdTuberculosis.setChecked(pi.tuberculosis);

        RadioButton rdAIDSorHIV = (RadioButton) root.findViewById(R.id.rdAIDSorHIV);
        rdAIDSorHIV.setChecked(pi.AIDSorHIV);

        return root;
    }
 
}